import java.util.LinkedList;
import java.util.Queue;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-02-07
 * Time:21:03
 */

class RecentCounter {

    Queue<Integer> queue;
    public RecentCounter() {
        queue = new LinkedList<>();
    }

    public int ping(int t) {
        queue.add(t);
        int time = queue.peek();
        while(time<t-3000){
            queue.poll();
            time = queue.peek();
        }
        return queue.size();
    }
}

public class test {

}
